<template>
  <div class="app-container">
    <div class="filter-container">
        <!-- <el-input v-model="listQuery.name" placeholder="用户账号" class="filter-item" clearable/> -->
      <el-select v-model="listQuery.type" placeholder="类型" class="filter-item">
        <el-option v-for="item in typeJson" :key="item.value" :label="item.label" :value="item.value" />
      </el-select>
        <div class="filter-item">
        <div class="searchItem">
          <span class="searchLabel">筛选日期：</span>
          <DatePicker :mode="1" :startDate.sync="listQuery.beginTime" :endDate.sync="listQuery.endTime" clearable />
        </div>
      </div>
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="getList">
        查询
      </el-button>
    </div>
    <el-card class="box-card" shadow="hover">
      <div slot="header" class="clearfix">
        <span>业务员统计</span>
      </div>
      <el-table ref="table" v-loading="listLoading" :data="list" fit highlight-current-row row-key="id" style="width: 100%;">
        <el-table-column label="姓名" prop="name" align="center" />
        <el-table-column label="总单数" prop="num" align="center" />
        <el-table-column label="业务总金额" prop="amount" align="center" />
        <el-table-column label="客单价" prop="customerAmount" align="center" />
        <el-table-column v-if="typeFlag" label="省" prop="receiveProvinceName" align="center" />
        <el-table-column v-if="typeFlag" label="市" prop="receiveCityName" align="center" />
      </el-table>
      <Pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNo" :limit.sync="listQuery.pageSize"
      @pagination="getList" />
    </el-card>
  </div>
</template>

<script>

import { queryBusinessManDataAnalysis } from '@/api/zcyx'
import Pagination from '@/components/Pagination'
import DatePicker from '@/components/DatePicker'
import waves from '@/directive/waves'

export default {
  name: "BusinessManAnalysis",
  directives: { waves },
  props: {

  },
  components: {
    DatePicker,
    Pagination
  },
  data() {
    return {
      list: [],
      total: 0,
      listLoading: true,
      listQuery: {
        type: '1',
        name: '',
        beginTime: '',
        endTime: '',
        pageNo: 1,
        pageSize: 20,
      },
      typeJson: [
        { value: '1', label: '平台统计' },
        { value: '2', label: '区域统计' },
      ],
      typeFlag: false
    }
  },
  computed: {

  },
  watch: {},
  methods: {
    getList() {
      this.listLoading = true
      queryBusinessManDataAnalysis(this.listQuery).then(response => {
        this.list = response.list || []
        this.total = response.totalCount
        this.listLoading = false

        this.typeFlag = this.listQuery.type == 1 ? false : true
      }).catch(error => {
        console.log(error);
        this.listLoading = false
      })
    },
  },
  created() {
    this.getList()
  },
  mounted() {
    
  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {}, // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style lang='scss' scoped>
  .searchItem {
    display: flex;
    align-items: center;
    .searchLabel {
      color: #666;
    }
  }
</style>